package com.groupsix.filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * @author 董盛昌
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: 字符编码过滤器
 * @date 2021/10/18 15:04
 */
public class CharsetEncondings implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
        //设置编码格式
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");

        //工作移交
        filterChain.doFilter(request,response);//交给其他的过滤器处理
    }

    @Override
    public void destroy() {

    }
}
